import axios from 'axios'
//上线  'http://121.89.205.189:3000/api'
//开发阶段 遇到跨域问题
const myRequest = axios.create({
    baseURL: 'http://121.89.205.189:3000/api',
    timeout: 6000
})

//请求拦截器
myRequest.interceptors.request.use(config => {
    //对你的这次请求做了处理
    let token = localStorage.getItem('token');
    if (token) {
        config.headers.token = token
    }
    return config
}, (error) => {
    console.log(error);
})

//响应拦截器
myRequest.interceptors.response.use(response => {
    return response
}, (error) => {
    console.log(error);
})

export default myRequest